import request from "utils/request";
import { routerRedux } from "dva/router";
export default {
  namespace: "global",
  state: {
    服务器地址: "127.0.0.1:8050",
    服务器UDP地址: "127.0.0.1:8051",
    服务器接口地址: "127.0.0.1:8052",
    本地端口: "8053",
    昵称: "oldfeel",
    显示服务器配置: false,
    currentUser: {},
    是否配置服务器: false
  },
  effects: {
    *获取用户信息(_, { call, put }) {
      const 请求结果 = yield request("用户/获取用户信息");
      if (请求结果 && 请求结果.code == 0) {
        yield put({ type: "save", currentUser: 请求结果.data });
      }
    },
    *注销登录(_, { put }) {
      localStorage.Token = "";
      yield put(routerRedux.push("/login"));
    }
  },
  reducers: {
    save(state, action) {
      return {
        ...state,
        ...action
      };
    }
  },
  subscriptions: {}
};
